<template>
  <homePanelVue title="热门品牌" sub-title="国际经典 品质保障">
    <template #main>
      <ul class="brand-list">
        <li v-for="item in brandList" :key="item.id">
          <img v-lazy-img="item.picture" alt="" />
          <div class="boxDiv">
            <p class="name">{{ item.name }}</p>
            <p class="desc">{{ item.desc }}</p>
          </div>
        </li>
      </ul>
    </template>
  </homePanelVue>
</template>

<script>
// 引入子组件
import homePanelVue from './home-panel.vue'
// 引入接口
import { getBrand } from '@/api/home.js'
import { ref } from 'vue'
export default {
  name: 'HomeBrand',
  components: {
    homePanelVue
  },
  setup () {
    // 1.定义响应式数据
    const brandList = ref([])
    // 2.定义函数 函数内部调用接口函数
    async function getNewList () {
      const res = await getBrand()
      brandList.value = res
    }
    getNewList()
    return {
      brandList
    }
  }
}
</script>

<style scoped lang="less">
.brand-list {
  display: flex;

  li {
    flex: 1;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    .boxDiv {
      p {
        font-size: 22px;
        padding-top: 12px;
        text-align: center;
      }
      .desc {
        color: #999;
        font-size: 18px;
      }
    }
  }
}
</style>
